package com.ihr360.expr;


import com.ihr360.expr.core.Expr;
import com.ihr360.expr.core.ExprType;

/**
 * 错误提示
 */
public class ExprError extends Expr {
    public static final Expr NULL = new ExprError("#NULL!", "Null Error");
    public static final Expr DIV0 = new ExprError("#DIV/0!",
            "Divide by Zero Error");
    public static final Expr VALUE = new ExprError("#VALUE", "Error in Value");
    public static final Expr REF = new ExprError("#REF!", "Reference Error");
    public static final Expr NAME = new ExprError("#NAME?",
            "Invalid Name Error");
    public static final Expr NUM = new ExprError("#NUM!", "Number Error");
    public static final Expr NA = new ExprError("#N/A", "Value not Available");

    public static final Expr INDEX_RANGE = new ExprError("#ERROR!", "Index of Array out of Range");

    private String errType;
    private String message;

    private String variableId;

    public ExprError(String type, String message) {
        super(ExprType.Error, false);
        this.errType = type;
        this.message = message;
    }

    public ExprError(String type, String message, String variableId) {
        super(ExprType.Error, false);
        this.errType = type;
        this.message = message;
        this.variableId = variableId;
    }

    public String getErrType() {
        return errType;
    }

    public String getMessage() {
        return message;
    }

    public String getVariableId() {
        return variableId;
    }

    public void setVariableId(String variableId) {
        this.variableId = variableId;
    }

    public String toString() {
        return "#" + message;
    }
}
